package org.alala.datamodels.common.query;

import java.io.Serializable;
import java.util.List;

/**
 * 共通数据返回model
 * 
 * @author huojinguang
 *
 * @param <T>
 */
public class QueryResult<T> extends BasicQueryResult implements Serializable {
	
	private static final long serialVersionUID = 6654929295670413737L;
	private int page;
	private int total;
	private int pageSize;
	private int objType;
	private boolean ended;
	private List<T> results;
	private Object extra;
	
	public QueryResult(List<T> results) {
		this.results = results;
	}

	public QueryResult(long count, List<T> results) {
		this.count = count;
		this.results = results;
	}

	public List<T> getResults() {
		return results;
	}

	public void setResults(List<T> result) {
		this.results = result;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getObjType() {

		return objType;
	}

	public void setObjType(int objType) {

		this.objType = objType;
	}

	public boolean isEnded() {
		return ended;
	}

	public void setEnded(boolean ended) {
		this.ended = ended;
	}

	public Object getExtra() {
		return extra;
	}

	public void setExtra(Object extra) {
		this.extra = extra;
	}
	
	
	private static final QueryResult<?> EMPTY_RESULT;
	
	static {
		EMPTY_RESULT = new QueryResult<>(null);
		EMPTY_RESULT.ended = true;
	}

	@SuppressWarnings("unchecked")
	public static <T> QueryResult<T> emptyResult(){
		return (QueryResult<T>)EMPTY_RESULT;
	}
}
